<!DOCTYPE html>
<html lang="en">
  <head>
      <meta charset="UTF-8">
      <title>json对象和json字符串转换</title>
    <script type="text/javascript">
      window.onload = function () {
        //Json是一个 js的内置(build-in)对象

        //Json对象转成String
        var jsonPerson = {
          "name":"jack",
          "age":20
        }
        var stringPerson = JSON.stringify(jsonPerson);
        console.log(stringPerson, typeof stringPerson)

        //String转成Json对象
        var json = JSON.parse(stringPerson);
        console.log(json, typeof json)
      }
    </script>
  </head>
  <body>
    <h1>JSON对象和字符串对象转换</h1>
  </body>
</html>